function [img, count, max_avail] = f5e_simple(img, k, msg, start)
    % F5E_SIMPLE  Embed message using F5.

    if k <= 0
        error('k must be above zero.');
    end
    n = 2^k - 1;

    % patch OBIN
    obin = arrayToBinary(msg);
    data_size = size(obin,2);
    if mod(data_size, k) ~= 0
        morebit = k - mod(data_size,k);
    else
        morebit = 0;
    end
    bin = [obin, zeros(1, morebit)];
    data_size = size(bin,2);

    ROWS = size(img,1)/8;
    r = int16(im2vec(img, [8 8])');
    [M,N] = size(r);
    
    max_avail = countNonZero(r);
    disp(sprintf('max_avail = %db',max_avail));

    % matrix F5
    count = 1;    
    usedval = ones(1,n) * -1;
    usedi = usedval;
    usedj = usedval;
    usedlen = 1;
    p = 0;
    for i = 1:M
        if count > data_size
            break
        end
        for j = 2:N
            if count > data_size
                break
            end
            p = p + 1;
            if r(i,j) == 0
                continue
            end
            usedi(1, usedlen) = i;
            usedj(1, usedlen) = j;
            usedval(1, usedlen) = r(i,j);
            usedlen = usedlen + 1;
            if usedlen > n
                [fb, ndata] = f5_setValue(usedval, bin(1, count:count+k-1), k, n);
                for z = 1:n
                    r(usedi(z), usedj(z)) = ndata(z);
                end
                if fb >= 0
                    usedval = [usedval(1:fb-1), usedval(fb+1:n), -1];
                    usedi = [usedi(1:fb-1), usedi(fb+1:n), -1];
                    usedj = [usedj(1:fb-1), usedj(fb+1:n), -1];
                    usedlen = usedlen - 1;
                else
                    usedval = ones(1,n) * -1;
                    usedi = usedval;
                    usedj = usedval;
                    usedlen = 1;
                    count = count + k;
                end
            end
        end
    end
    
    count = count - 1;
    img = vec2im(double(r)', [0 0], [8 8], ROWS);
    
    % output
    if count < data_size
        len = floor((count-16)/8);
        disp(sprintf('part of message hidden in whole image. %3.3f bpp, %3.3f bpc', count/M/N, count/max_avail));
        disp(sprintf(' msg = %dB (%db), %3.2f%%',len, count,100*count/data_size));
    else
        disp(sprintf('whole message hidden in part of image. %3.3f bpp, %3.3f bpc', count/M/N, count/max_avail));
        disp(sprintf(' coef = %db, %3.2f%%',p,100*p/M/N));
    end
end
